package com.gs.SynPatrolRep.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.TextView;


import androidx.core.content.res.ResourcesCompat;

import com.gs.SynPatrolRep.R;
import com.gs.SynPatrolRep.adapter.base.BaseAdapter;
import com.gs.SynPatrolRep.adapter.base.BaseViewHolder;
import com.gs.SynPatrolRep.db.dto.PalBillSiteDto;

import java.util.List;

public class PalBillSiteAdapter extends BaseAdapter<PalBillSiteDto> {

    private int what;

    public PalBillSiteAdapter(Context context, List<PalBillSiteDto> mData, int layoutId,int what) {
        super(context, mData, layoutId);
        this.what = what;
    }

    @Override
    public void convert(BaseViewHolder holder, PalBillSiteDto bean, int position) {
        if (what == 0) {
            if (bean.getLblType() != null) {
                switch (bean.getLblType()) {
                    case 1:
                        holder.setImageResource(R.id.iv_icon, R.drawable.ic_gray_scan);
                        break;
                    case 2:
                        holder.setImageResource(R.id.iv_icon, R.mipmap.bluetooth);
                        break;
                    case 3:
                        holder.setImageResource(R.id.iv_icon, R.mipmap.nfc);
                        break;
                }
            }
        }else {
            holder.setVisibility(R.id.iv_icon, View.GONE);
        }
        TextView tv = holder.fd(R.id.tv_inspection);
        tv.setText(bean.getSiteName() == null ? "" : bean.getSiteName());
        tv.setSelected(bean.getSelect() == null ? false : bean.getSelect());
        holder.setSelected(R.id.ll_inspection, bean.getSelect() == null ? false : bean.getSelect());
    }

    public void changeSelect(int position) {
        for (int i = 0; i < getItemCount(); i++) {
            list.get(i).setSelect(false);
        }
        list.get(position).setSelect(true);
        notifyDataSetChanged();
    }
}
